home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / c_lib01.arc / PRINTF.C < prev    next >
Text File  |  1985-10-16  |  1KB  |  48 lines

  1. /*
  2. **       name         printf -- formatted write to console.
  3. **
  4. **       Same as Lattice C printf() function, but much faster.
  5. */
  6.  
  7. printf(cs, args)
  8. char *cs, *args;
  9. {
  10.         int i, c, n;
  11.         char *p, **na, *_pfmt();
  12.         char work[256];
  13.  
  14.         na =  &args;           /* point to first arg */
  15.         while (*cs)
  16.         {
  17.                 c = *cs++;
  18.                 if (c == '%')
  19.                         if (*cs == '%')
  20.                         {
  21.                                 c = *cs++;
  22.                                 chrout(c);
  23.                         }
  24.                 else
  25.                 {
  26.                         p = _pfmt(cs, work, &na, &n);
  27.                         if (p)
  28.                         {
  29.                                 cs = p;
  30.                                 for (i=0; i<n; i++)
  31.                                         chrout(work[i]);
  32.                         }
  33.                 }
  34.                 else
  35.                         chrout(c);
  36.         }
  37.         return;
  38. }
  39.  
  40. chrout(c)
  41. char c;
  42. {
  43.         if (c == '\n')
  44.                 bdos(2,'\r');
  45.         bdos(2,c);
  46. }
  47.  
  48.